{
	
	
label var D_sourcing "\$Relational^D_b\$" 
label var S_sourcing "\$Relational_b\$" 
label var w_r "\$(F/Q)_b\$" 


capture drop TEMP_SAMPLE
reghdfe ln_p_inpf_sbjo  S_sourcing  ln_q_sb_all sh_s_b sh_b_s age_buysel_month  ///
 ln_q_b_all age_buy_month  ln_q_inpf signatory ///
if sample==1, ///
abs(gr_sjt top_dest_b cohort_sb cohort_b) vce (cluster b_id)
gen TEMP_SAMPLE=e(sample)

capture drop sample
gen sample=(n_ud==1 & S_pds==1)

gen month2=month^2
gen month3=month^3

eststo clear
eststo:  ///
reghdfe ln_qf_UD_imp ln_q_sbjo ln_cotton_price month if sample==1, abs(gr_sj) vce(cluster gr_sj)
    estadd local FE ="sj", replace  
  quietly estadd local CRTL1 ="\scriptsize{1}", replace  
  quietly estadd local CRTL2 ="Yes", replace  
eststo:  ///  
reghdfe ln_qf_UD_imp ln_q_sbjo  month_post_nov2010 month if sample==1, abs(gr_sj) vce(cluster gr_sj)
  quietly estadd local FE ="sj", replace  
  quietly estadd local CRTL1 ="\scriptsize{1}", replace  
  quietly estadd local CRTL2 ="Yes", replace  
eststo:  ///  
reghdfe ln_qf_UD_imp ln_q_sbjo ln_cotton_price  month_post_nov2010 month if sample==1, abs(gr_sj) vce(cluster gr_sj)
  quietly estadd local FE ="sj", replace  
  quietly estadd local CRTL1 ="\scriptsize{1}", replace  
  quietly estadd local CRTL2 ="Yes", replace  
eststo:  ///  
reghdfe ln_qf_UD_imp ln_q_sbjo ln_cotton_price  month_post_nov2010 month month2 month3 if sample==1, abs(gr_sj) vce(cluster gr_sj)
  quietly estadd local FE ="sj", replace  
  quietly estadd local CRTL1 ="\scriptsize{1,2,3}", replace  
  quietly estadd local CRTL2 ="Yes", replace  
eststo:  ///  
reghdfe ln_qf_UD_imp ln_q_sbjo ln_cotton_price  month_post_nov2010 ///
c.ln_cotton_price#i1.D_sourcing  c.month_post_nov2010#i1.D_sourcing D_sourcing ///
 month month2 month3  if sample==1, abs(gr_sj) vce(cluster gr_sj)
  quietly estadd local FE ="sj", replace  
  quietly estadd local CRTL1 ="\scriptsize{1,2,3}", replace  
  quietly estadd local CRTL2 ="Yes", replace  
eststo:  ///  
reghdfe ln_qf_UD_imp ln_q_sbjo ln_cotton_price  month_post_nov2010 ///
c.ln_cotton_price#i1.D_sourcing  c.month_post_nov2010#i1.D_sourcing D_sourcing ///
 month month2 month3 if TEMP_SAMPLE==1, abs(gr_sj) vce(cluster gr_sj)
  quietly estadd local FE ="sj", replace  
  quietly estadd local CRTL1 ="\scriptsize{1,2,3}", replace   
  quietly estadd local CRTL2 ="Yes", replace  
eststo:  ///  
 reghdfe ln_qf_UD_imp ln_q_sbjo ln_cotton_price  month_post_nov2010 ///
c.ln_cotton_price#i1.D_sourcing  c.month_post_nov2010#i1.D_sourcing D_sourcing ///
 month month2 month3 if TEMP_SAMPLE==1, abs(gr_sjt top_dest_b) vce(cluster gr_sj)  
  quietly estadd local FE ="sjt,d", replace  
  quietly estadd local CRTL1 ="\scriptsize{1,2,3}", replace   
  quietly estadd local CRTL2 ="Yes", replace  
  
esttab using "${tables}\TableE2PanelA.tex", ///
  label replace booktabs b(3) se(3) noconstant obslast substitute(\_ _) ///
    title("Buyers' Sourcing and Input Substitution" \label{Substitution}) ///
  drop(month  D_sourcing  month2 month3 _cons) order(ln_cotton_price  month_post_nov2010 ln_q_sbjo ) /// 
  stats(   FE CTRL1 r2   N   , fmt(   %~#s  %~#s 2  %12.0fc  )  ///
  labels(   "FEs" "Time Trend"  `"\(R^{2}\)"'  "Obs."  ))   ///
  star(* 0.10 ** 0.05 *** 0.01) ///
  nonotes  	

  
eststo clear
eststo:  ///
reghdfe w_r  ln_cotton_price month if sample==1, abs(gr_sj) vce(cluster gr_sj)
    estadd local FE ="sj", replace  
  quietly estadd local CRTL1 ="\scriptsize{1}", replace  
  quietly estadd local CRTL2 ="Yes", replace  
eststo:  ///  
reghdfe w_r   month_post_nov2010 month if sample==1, abs(gr_sj) vce(cluster gr_sj)
  quietly estadd local FE ="sj", replace  
  quietly estadd local CRTL1 ="\scriptsize{1}", replace  
  quietly estadd local CRTL2 ="Yes", replace  
eststo:  ///  
reghdfe w_r  ln_cotton_price  month_post_nov2010 month if sample==1, abs(gr_sj) vce(cluster gr_sj)
  quietly estadd local FE ="sj", replace  
  quietly estadd local CRTL1 ="\scriptsize{1}", replace  
  quietly estadd local CRTL2 ="Yes", replace  
eststo:  ///  
reghdfe w_r  ln_cotton_price  month_post_nov2010 month month2 month3 if sample==1, abs(gr_sj) vce(cluster gr_sj)
  quietly estadd local FE ="sj", replace  
  quietly estadd local CRTL1 ="\scriptsize{1,2,3}", replace  
  quietly estadd local CRTL2 ="Yes", replace  
eststo:  ///  
reghdfe w_r  ln_cotton_price  month_post_nov2010 ///
c.ln_cotton_price#i1.D_sourcing  c.month_post_nov2010#i1.D_sourcing D_sourcing ///
 month month2 month3  if sample==1, abs(gr_sj) vce(cluster gr_sj)
  quietly estadd local FE ="sj", replace  
  quietly estadd local CRTL1 ="\scriptsize{1,2,3}", replace  
  quietly estadd local CRTL2 ="Yes", replace  
eststo:  ///  
reghdfe w_r  ln_cotton_price  month_post_nov2010 ///
c.ln_cotton_price#i1.D_sourcing  c.month_post_nov2010#i1.D_sourcing D_sourcing ///
 month month2 month3 if TEMP_SAMPLE==1, abs(gr_sj) vce(cluster gr_sj)
  quietly estadd local FE ="sj", replace  
  quietly estadd local CRTL1 ="\scriptsize{1,2,3}", replace   
  quietly estadd local CRTL2 ="Yes", replace  
eststo:  ///  
 reghdfe w_r  ln_cotton_price  month_post_nov2010 ///
c.ln_cotton_price#i1.D_sourcing  c.month_post_nov2010#i1.D_sourcing D_sourcing ///
 month month2 month3 if TEMP_SAMPLE==1, abs(gr_sjt top_dest_b) vce(cluster gr_sj)  
  quietly estadd local FE ="sjt,d", replace  
  quietly estadd local CRTL1 ="\scriptsize{1,2,3}", replace   
  quietly estadd local CRTL2 ="Yes", replace  
  
esttab using "${tables}\TableE2PanelB.tex", ///
  label replace booktabs b(3) se(3) noconstant obslast substitute(\_ _) ///
    title("Buyers' Sourcing and Input Substitution" \label{Substitution}) ///
  drop(month  D_sourcing month2 month3 _cons) order(ln_cotton_price  month_post_nov2010  ) /// 
  stats(   FE CTRL1 r2   N   , fmt(   %~#s  %~#s 2  %12.0fc  )  ///
  labels(   "FEs" "Time Trend"  `"\(R^{2}\)"'  "Obs."  ))   ///
  star(* 0.10 ** 0.05 *** 0.01) ///
  nonotes  	 
 } 
 